package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.corona.Game;
import com.corona.game.util.TextureCache;
import java.util.ArrayList;

/* compiled from: Battle.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/ThrowOutPokemon.class */
public class ThrowOutPokemon extends Action {
    Sprite pokeballSprite;
    Sprite[][] sprite;
    ArrayList<Integer> repeats;
    ArrayList<String> sounds;
    String sound;
    Sprite helperSprite;
    public Action.Layer layer = Action.Layer.gui_104;
    boolean firstStep = true;
    boolean doneYet = false;
    Vector2 position = new Vector2(16.0f, 32.0f);
    ArrayList<Vector2> positions = new ArrayList<>();
    ArrayList<Sprite[][]> sprites = new ArrayList<>();

    /* JADX DEBUG: Multi-variable search result rejected for r0v66, resolved type: com.badlogic.gdx.graphics.g2d.Sprite[][][][] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v24, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v26, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v30, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v32, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v78, resolved type: com.badlogic.gdx.graphics.g2d.Sprite[][][][] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v36, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v40, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v138, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v141, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v54, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v55, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v143, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v57, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v58, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v145, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v147, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r1v93, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v151, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v63, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v64, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v153, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v66, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v67, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v155, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v69, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v70, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v157, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v72, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r2v73, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v159, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v161, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v165, resolved type: com.badlogic.gdx.graphics.g2d.Sprite[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v167, resolved type: java.lang.Object[] */
    /* JADX DEBUG: Multi-variable search result rejected for r0v168, resolved type: com.badlogic.gdx.graphics.g2d.TextureAtlas$AtlasSprite */
    /* JADX WARN: Multi-variable type inference failed */
    public ThrowOutPokemon(Game game, Action nextAction) {
        super(new Object[0]);
        this.nextAction = nextAction;
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(-6.0f, 18.0f));
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(0.0f, 0.0f));
        this.positions.add(new Vector2(12.0f, 12.0f));
        this.sprites.add(null);
        Texture text = TextureCache.get(Gdx.files.internal("poof_sheet1.png"));
        this.sprites.add(new Sprite[][]{new Sprite[]{new Sprite(text, 0, 0, 48, 48)}});
        this.sprites.add(new Sprite[][]{new Sprite[]{new Sprite(text, 48, 0, 48, 48)}});
        this.sprites.add(new Sprite[][]{new Sprite[]{new Sprite(text, 96, 0, 48, 48)}});
        this.sprites.add(new Sprite[][]{new Sprite[]{new Sprite(text, 144, 0, 48, 48)}});
        this.sprites.add(new Sprite[][]{new Sprite[]{new Sprite(text, 192, 0, 48, 48)}});
        this.sprites.add(null);
        TextureRegion[][] tempRegion = new Sprite((Sprite) game.player.currPokemon.backSprite).split(4, 4);
        Sprite[][][][] spriteArr = new Sprite[7][7][];
        for (int i = 0; i < tempRegion.length; i++) {
            for (int j = 0; j < tempRegion[i].length; j++) {
                spriteArr[i][j] = new Sprite(tempRegion[6 - j][i]);
                spriteArr[i][j].setScale(2.0f);
            }
        }
        for (int i2 = 0; i2 < spriteArr.length; i2++) {
            spriteArr[i2][2] = spriteArr[i2][3];
            spriteArr[i2][3] = spriteArr[i2][5];
            spriteArr[i2][4] = spriteArr[i2][6];
            spriteArr[i2][5] = 0;
            spriteArr[i2][6] = 0;
        }
        spriteArr[2] = spriteArr[1];
        spriteArr[1] = spriteArr[0];
        spriteArr[0] = new Sprite[0];
        spriteArr[4] = spriteArr[5];
        spriteArr[5] = spriteArr[6];
        spriteArr[6] = new Sprite[0];
        Sprite[][][][] spriteArr2 = new Sprite[7][7][];
        for (int i3 = 0; i3 < spriteArr.length; i3++) {
            for (int j2 = 0; j2 < spriteArr[i3].length; j2++) {
                spriteArr2[i3][j2] = spriteArr[i3][j2];
            }
        }
        for (int i4 = 0; i4 < spriteArr2.length; i4++) {
            if (spriteArr2[i4].length > 0) {
                spriteArr2[i4][1] = spriteArr2[i4][2];
                spriteArr2[i4][2] = spriteArr2[i4][4];
                spriteArr2[i4][3] = 0;
                spriteArr2[i4][4] = 0;
            }
        }
        spriteArr2[2] = spriteArr2[1];
        spriteArr2[1] = new Sprite[0];
        spriteArr2[4] = spriteArr2[5];
        spriteArr2[5] = new Sprite[0];
        Sprite temp4 = new Sprite(tempRegion[0][4]);
        temp4.setScale(2.0f);
        this.sprites.add(new Sprite[][]{new Sprite[0], new Sprite[0], new Sprite[0], new Sprite[]{temp4}});
        this.sprites.add(spriteArr2);
        this.sprites.add(spriteArr);
        this.sprites.add(new Sprite[][]{new Sprite[]{game.player.currPokemon.backSprite}});
        this.repeats = new ArrayList<>();
        this.repeats.add(40);
        for (int i5 = 0; i5 < 4; i5++) {
            this.repeats.add(5);
        }
        this.repeats.add(10);
        this.repeats.add(1);
        this.repeats.add(3);
        this.repeats.add(3);
        this.repeats.add(6);
        this.sounds = new ArrayList<>();
        this.sounds.add(null);
        this.sounds.add("poof1");
        for (int i6 = 0; i6 < 9; i6++) {
            this.sounds.add(null);
        }
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.firstStep) {
            game.battle.drawAction.drawFriendlyPokemonAction = this;
            this.firstStep = false;
        }
        this.sprite = this.sprites.get(0);
        if (this.positions.isEmpty() || this.sprites.isEmpty()) {
            if (!this.doneYet) {
                game.insertAction(this.nextAction);
                game.player.currPokemon.backSprite.setPosition(this.position.x, this.position.y);
                for (int i = 0; i < this.sprite.length; i++) {
                    for (int j = 0; j < this.sprite[i].length; j++) {
                        this.sprite[i][j].setPosition(this.position.x, this.position.y);
                    }
                }
                this.doneYet = true;
                this.layer = Action.Layer.gui_114;
                game.actionStack.remove(this);
                game.insertAction(this);
            }
            for (int i2 = 0; i2 < this.sprite.length; i2++) {
                for (int j2 = 0; j2 < this.sprite[i2].length; j2++) {
                    this.sprite[i2][j2].draw(game.uiBatch);
                }
            }
            if (game.battle.drawAction == null) {
                game.actionStack.remove(this);
                return;
            }
            return;
        }
        if (this.sprite != null) {
            for (int i3 = 0; i3 < this.sprite.length; i3++) {
                for (int j3 = 0; j3 < this.sprite[i3].length; j3++) {
                    if (this.sprite[i3][j3] != null) {
                        this.sprite[i3][j3].setPosition(this.position.x + ((float) (8 * i3)), this.position.y + ((float) (8 * j3)));
                        this.sprite[i3][j3].draw(game.uiBatch);
                    }
                }
            }
        }
        this.sound = this.sounds.get(0);
        if (this.sound != null) {
            game.insertAction(new PlayMusic(this.sound, (Action) null));
            this.sounds.set(0, null);
        }
        if (this.repeats.get(0).intValue() > 1) {
            this.repeats.set(0, Integer.valueOf(this.repeats.get(0).intValue() - 1));
            return;
        }
        this.position = this.position.add(this.positions.get(0));
        this.positions.remove(0);
        this.sprites.remove(0);
        this.repeats.remove(0);
        this.sounds.remove(0);
    }
}
